package shujvjiegou.wekk2;

import java.util.ArrayList;
import java.util.Scanner;

public class ZeroChoice {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int length = scan.nextInt();
        String temp;
        ArrayList<String> list = new ArrayList<>();
        int count = 0;

        for (int i = 0; i < length; i++) {
            temp = scan.next();
            if (temp.equals("0")) {
                count++;
            } else {
                list.add(temp);
            }
        }
        for (int j = 0; j < count; j++) {
            list.add(j, "0");
        }
        for (int i = 0; i < length; i++) {
            System.out.print(list.get(i) + " ");
        }
    }
}
